<template>
  <div class="vueBox">
    <div class="marquee">
      <div class="marquee_title">
        <span>证件到期</span>
      </div>
      <div class="marquee_box">
        <ul class="marquee_list" :class="{marquee_top:animate}">
          <li v-for="(item, index) in marqueeList" :key="index">
            <span class="com_name">{{ item.name }}</span>
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      animate: false,
      marqueeList: [
        {
          name: 'AAAAAAAAAAA公司'
        },
        {
          name: 'BBBBBBBBBB公司'
        },
        {
          name: 'CCCCCCCCC公司'
        },
        {
          name: 'DDDDDDDDDD公司'
        }
      ]
    }
  },
  created: function() {
    setInterval(this.showMarquee, 2000)
  },
  methods: {
    showMarquee: function() {
      this.animate = true
      setTimeout(() => {
        this.marqueeList.push(this.marqueeList[0])
        this.marqueeList.shift()
        this.animate = false
      }, 500)
    }
  }
}
</script>

<style scoped>
div, ul, li, span, img {
  margin: 0;
  padding: 0;
  display: flex;
  box-sizing: border-box;
}
.marquee {
  width: 100%;
  height: 30px;
  align-items: center;
  color: #6984C1;
  display: flex;
  box-sizing: border-box;
}

.marquee_title {
  padding: 0 20px;
  height: 30px;
  font-size: 16px;
  align-items: center;
}

.marquee_box {
  display: block;
  position: relative;
  width: 60%;
  height: 30px;
  overflow: hidden;
}

.com_name {
  width: 170px;
  display: inline-block;
  overflow: hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.marquee_list {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
}
.marquee_top {
  transition: all 0.5s;
  margin-top: -30px
}

.marquee_list li {
  height: 30px;
  line-height: 30px;
  font-size: 16px;
  padding-left: 5px;
}

.marquee_list li span {
  padding: 0 2px;
}

</style>

